Prevent an oops in Dom0 that occurs when a CD device, specified as one
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Tue, 16 May 2006 08:40:38 +0000 (09:40 +0100)
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Tue, 16 May 2006 08:40:38 +0000 (09:40 +0100)
of the 'hardrives' in the 'disk=' line of a para-virtualized guest's
def file, has no media when the guest is started.

The oops occurs in vbd.c when vbd_size() is called from connect() (in
xenbus.c) and the vbd pointer is really an error code that comes from
the failed open that occurred in vbd_create().

Based on a patch from Ross Maxfield at Novell.

Signed-off-by: Keir Fraser <keir@xensource.com>
linux-2.6-xen-sparse/drivers/xen/blkback/vbd.c

index d1d38dcd767fb97ed0a7c58b10497950893ce06a..3c4a3b13a39612578fb343f0fb035a21dc8e4bc3 100644 (file)
@@ -55,6 +55,7 @@ int vbd_create(blkif_t *blkif, blkif_vdev_t handle, unsigned major,
               unsigned minor, int readonly)
 {
        struct vbd *vbd;
+       struct block_device *bdev;
 
        vbd = &blkif->vbd;
        vbd->handle   = handle; 
@@ -63,15 +64,17 @@ int vbd_create(blkif_t *blkif, blkif_vdev_t handle, unsigned major,
 
        vbd->pdevice  = MKDEV(major, minor);
 
-       vbd->bdev = open_by_devnum(
-               vbd->pdevice,
-               vbd->readonly ? FMODE_READ : FMODE_WRITE);
-       if (IS_ERR(vbd->bdev)) {
-               DPRINTK("vbd_creat: device %08x doesn't exist.\n",
+       bdev = open_by_devnum(vbd->pdevice,
+                             vbd->readonly ? FMODE_READ : FMODE_WRITE);
+
+       if (IS_ERR(bdev)) {
+               DPRINTK("vbd_creat: device %08x could not be opened.\n",
                        vbd->pdevice);
                return -ENOENT;
        }
 
+       vbd->bdev = bdev;
+
        if (vbd->bdev->bd_disk == NULL) {
                DPRINTK("vbd_creat: device %08x doesn't exist.\n",
                        vbd->pdevice);